-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add board: Seeed XIAO BLE #2591
Conversation
Thanks - this looks great! Do you think it'd be possible to change |
6fc4180
to
44d2473
Compare
Thanks for the feedback! |
Does the board definition file need to use |
boards/XIAOBLE.py
Outdated
"link": ["https://www.seeedstudio.com/Seeed-XIAO-BLE-nRF52840-p-5201.html"], | ||
"default_console": "EV_USBSERIAL", | ||
"variables": 14000, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile. | ||
"binary_name": "espruino_%v_xiaoble.hex", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this is .uf2? It may be you don't need the ifdef XIAOBLE ... proj: $(PROJ_NAME).uf2
line if it is...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoding only the XIAOBLE to create a UF2 in that makefile does seem rather hacky...
Turns out I needed to change a bit more; something kept adding ".hex" to the end of the binary name.
See d40b0ca for what I did to make this work :)
@@ -2887,6 +2887,14 @@ void jshReboot() { | |||
NVIC_SystemReset(); | |||
} | |||
|
|||
#ifdef ESPR_HAS_BOOTLOADER_UF2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks! Please could you add a comment in https://github.com/espruino/Espruino/blob/master/README_BuildProcess.md#infomakefile-definitions though? I'm trying to keep all the defines documented somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 👍
Reminder for future me: Do this for BLE private address support as well.
src/jsflash.c
Outdated
@@ -1374,6 +1374,7 @@ JsVar *jsfGetBootCodeFromFlash(bool isReset) { | |||
|
|||
bool jsfLoadBootCodeFromFlash(bool isReset) { | |||
// Load code in .bootFirst at first boot UNLESS BTN1 IS HELD DOWN (BTN3 for Dickens) | |||
#ifndef ESPR_NO_BOOT_JS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a shame the board doesn't have a button so this is needed - but I feel like it's very unlikely anyone would make a custom build that includes this?
Maybe you could:
- Make the UF2 include the flash area used for saved code so it always overwrites it
- Make a special UF2 that just overwrites the saved code area to allow you to clear it if you want to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I feel like it's very unlikely anyone would make a custom build that includes this
Yeah, you're probably right.
The board does have a (reset) button; pressing it just immediately resets the board...
Make the UF2 include the flash area used for saved code
Probably not an option if saved code is on SPI flash though 🙈
(And I really want to use those 2 MB of external flash.)
Make a special UF2 that just overwrites the saved code area
I'd rather have something that allows recovering other data saved to storage, but I guess this will be the way to go if you don't like the "pull a magic pin to ground on boot" thing I added with my latest push.
Thanks for those changes to UF2 reboot - that looks really good.
No, that's fine - generate_pins was just a utility function to generate a bunch of contiguous pins. If you want to renumber the pins so they match the board what you've done is the right way to handle it. |
Thanks for the review!
If you think that the whole skipping boot js stuff is not that good of an idea I'll just drop that for now and look into the other recovery option you suggested, where we'd have an "I messed up and want to reset my board" build. |
Thanks! This is looking really good.
As D1 is configured as the button in the bootloader anyway, could we not just add |
Minimal code changes to achieve the same thing, sounds neat! I don't really like having those Do you think having D1 / BTN1 as IN_PULLDOWN or IN_PULLUP would be better? |
Thank you both for your work 😄 When trying the firmware from the build artifacts, I noticed that some pins are not working. D6 to D10 have a wrong Also: The the pin definitions >= D12 have different pin numbers assigned than mentioned in variant.cpp or the pinout sheet. This might be mostly cosmetic, but poses an inconsistency with Seeed's docs. (Unfortunately, I'm not yet able to get the build process running myself, via dockerfile. Compiling any board fails with |
on devices that have such a bootloader the device will reappear as a USB drive
@jj12 Thanks, nice catch! About your build issues: Just that message isn't a lot to go by, but can you build from |
Yup, can confirm, all pins work now. Thanks! Building is not related to your PR, it was based on |
I think pulldown is probably best as well - otherwise we'd have to get it to 'invert' the state in software as well.
Have you tried without those IFDEFs? It might have been a bit of a red herring - because normally we detect the button press at boot through: https://github.com/espruino/Espruino/blob/master/targets/nrf5x/main.c#L34 So I think if you wrote code to the device and then booted it while holding the button, it wouldn't be executed even without those ifdefs in jsflash. We also have this idea of I think the ifdefs for BANGLEJS are in there because in that case we wanted a way to boot into the recovery menu and ensure that absolutely nothing ever ran - but that's kind of an exception because we have an actual UI that can be displayed for recovery
Yes, the Docker build is a bit annoying and honestly I'm tempted to just remove that file. It was contributed but then not maintained, and given Github builds are just so easy, I think it's probably just wasting people's time having something that's not working in the repo. |
Pulldown it is 👍
Just tried again, without those let a = 42; to To simulate a button between pin D1 and 3V3, I've got a cable that bridges those pins on a breadboard. Things that do nothing while having D1 connected to 3V3:
With those I think the issue is that we read the button state in Line 37 in 672e959
and from that call jsiSemiInit(bool autoLoad, JsfFileName *loadedFilename) Line 982 in 672e959
where we do respect autoload Lines 889 to 897 in 672e959
but a few lines further down then invoke jsiSoftInit(bool hasBeenReset) Line 908 in 672e959
which in turn calls jsfLoadBootCodeFromFlash(bool isReset) Line 537 in 672e959
where we finally ignore isReset and load and execute .boot0 unconditionally, setting a to 42 :Lines 1393 to 1410 in 672e959
So to sum it up, we do: bool buttonState = jshPinGetValue(BTN1_PININDEX) == BTN1_ONSTATE;
bool isReset = !!buttonState;
{
char filename[7] = ".bootX";
for (int i=0;i<4;i++) {
filename[5] = (char)('0'+i);
JsVar *code = jsfReadFile(jsfNameFromString(filename),0,0);
if (code)
jsvUnLock2(jspEvaluateVar(code,0,0), code);
}
} And adding a if (isReset) {
return false;
} to the beginning of So the solution would be to replace the existing if (!(isReset &&
(jsiStatus & JSIS_FIRST_BOOT))) and thus keep us from entering the block that loads boot code on all boards if Still kind of paranoid about breaking other boards though 😅 Unless of course I've missed something 🙈 @jj12 If you haven't already figured this out yourself: Looks like FROM debian:bookworm
RUN apt-get update && apt-get upgrade -y && apt-get install -y build-essential gcc-arm-none-eabi tar python3 python3-pip python-is-python3 git curl unzip && apt-get clean
RUN pip install --break-system-packages protobuf==3.17.3
RUN pip install --break-system-packages --ignore-requires-python --no-deps nrfutil==6.1.7
RUN pip check | sed -e 's/^.*requires \(.*\),.*/\1/' > requirements.txt && pip install --break-system-packages -r requirements.txt && rm requirements.txt
RUN git config --global --add safe.directory '*'
RUN mkdir /espruino
RUN git clone 'https://github.com/espruino/Espruino.git' /espruino
WORKDIR /espruino
RUN bash -c 'source scripts/provision.sh BANGLEJS2'
RUN bash -c 'source scripts/provision.sh PUCKJS'
RUN bash -c 'source scripts/provision.sh EMSCRIPTEN2'
RUN bash -c 'source scripts/provision.sh JOLTJS' and remove/ replace the calls to docker build -t espruino_builder You can then run the container like this: mkdir -p build_output
docker run --rm -it -v "$(pwd)"/build_output:/espruino/bin espruino_builder /bin/bash and finally build for Bangle.js 2: make clean
BOARD=BANGLEJS2 RELEASE=1 DFU_UPDATE_BUILD=1 make or Linux: make clean
make Hope that helps :) |
I think this is exactly as expected. It's a bit like what I said with When you save to flash, the IDE saves to If you write to So I'll take out those extra IFDEFs so this port behaves like all the others and merge this in - you could maintain your own version with this change but I'd argue it's probably a lot easier just to write to
Thanks for spotting about the compiler download. Actually if arm-gcc exists on the path then provision won't try and download it, so probably the easiest is just to ensure that |
Thanks!
Alright, so that's what I missed 🤦
The provision script does print a nice huge warning message, that complains about the arm-gcc on the path having the wrong version; interesting that the difference between GCC versions can be so significant though. |
@ssievert42 Thanks a lot for the detailed information on your Dockerfile and steps, I was able to create my own build.
Finally also tried |
This adds support for the Seeed XIAO BLE, a tiny development board with a nRF52840 and 2 MB of external flash.
The board definition file is based on this one by Espruino forums user parasquid.
Some goodies that are included as well:
E.rebootToDFU()
triggers a reboot to UF2 bootloader mode